<?php	
	function insertAlbum(
		$p_album_title
			,$p_album_detail
			,$p_account_id
	
	){
		mysql_query("
			INSERT INTO TB_ALBUM(
				ALBUM_TITLE
					,ALBUM_DETAIL
					,ACCOUNT_ID
	
			)VALUES(
				'".$p_album_title."'
					,'".$p_album_detail."'
					,'".$p_account_id."'
	
			)	
		")or die(mysql_error());
		return mysql_insert_id();
	}
	
	function updateAlbum(
		$p_album_id
			,$p_album_title
			,$p_album_detail
			,$p_account_id
	
	){
		mysql_query("
			UPDATE TB_ALBUM 
			SET
				ALBUM_TITLE='".$p_album_title."'
					,ALBUM_DETAIL='".$p_album_detail."'
					,ACCOUNT_ID='".$p_account_id."'
	
			WHERE ALBUM_ID =  '".$p_album_id."'
		");
	}

	function getAllAlbum($p_where_clause,$p_offset,$p_num_row,$p_order_by=" ALBUM_ID DESC "){
		$rs = mysql_query("
		SELECT 
			ALBUM_ID
				,ALBUM_TITLE
				,ALBUM_DETAIL
				,ACCOUNT_ID

		FROM TB_ALBUM	
		WHERE 1 ".$p_where_clause."		
		ORDER BY ".$p_order_by."
		LIMIT ".$p_offset.",".$p_num_row."
		")or die(mysql_error());
		return $rs;
	}

	function getSingerAlbum($p_album_id){
		$rs = mysql_query("
		SELECT 
			ALBUM_ID
				,ALBUM_TITLE
				,ALBUM_DETAIL
				,ACCOUNT_ID

		FROM TB_ALBUM	
		WHERE ALBUM_ID =  '".$p_album_id."'		
		")or die(mysql_error());
		return $rs;
	}
	function getAlbumName ($p_album_id){
		$rs = getSingerAlbum($p_album_id);
		if ( $arr = mysql_fetch_assoc($rs) ){
			return $arr['ALBUM_TITLE'];
		}
		return '';
	}
	function getOwnerAlbum( $p_album_id ){
		$rs = getSingerAlbum($p_album_id);
		if ( $arr = mysql_fetch_assoc($rs) ){
			return $arr['ACCOUNT_ID'];
		}
		return '';
	} 
